//package com.bgl.mall.filter;
//
//import com.bgl.mall.common.Constant;
//import com.bgl.mall.pojo.User;
//import com.bgl.mall.util.CookieUtil;
//import com.bgl.mall.util.JsonUtil;
//import com.bgl.mall.util.RedisUtil;
//import com.bgl.mall.util.SpringContextUtils;
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.stereotype.Component;
//
//import javax.servlet.*;
//import javax.servlet.http.HttpServletRequest;
//import java.io.IOException;
//
///**
// * 重置登录session时间的过滤器
// * @author Bu Guoliang
// * @date 2019/07/12 21:06
// * @since 1.8
// */
//@Component
//public class SessionExpireFilter implements Filter {
//    @Override
//    public void init(FilterConfig filterConfig) throws ServletException {
//
//    }
//
//    @Override
//    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
//        HttpServletRequest request = (HttpServletRequest) servletRequest;
//        String loginToken = CookieUtil.readLoginToken(request);
//        if (StringUtils.isNotBlank(loginToken)) {
//            RedisUtil redisUtil = SpringContextUtils.getBean(RedisUtil.class);
//            String userJsonStr = (String) redisUtil.get(loginToken);
//            User user = JsonUtil.string2Obj(userJsonStr, User.class);
//            if (user != null) {
//                redisUtil.expire(loginToken, Constant.RedisCache.REDIS_SESSION_EXTIME);
//            }
//        }
//        filterChain.doFilter(servletRequest, servletResponse);
//    }
//
//    @Override
//    public void destroy() {
//
//    }
//}
